package object;

import java.util.Objects;

public class Point {//快捷键 alt + insert
    private int x;
    private int y;

    public Point() {
    }

    public Point(final int x, final int y) {
        this.x = x;
        this.y = y;
    }


    @Override   //this:p1   o:p2
    public boolean equals(final Object o) {
        if (this == o) return true;  //比地址
        if (null == o || this.getClass() != o.getClass()) return false;//getClass 获取的是类型
        final Point point = (Point) o;//强转，因为object o调用不了x和y
        return this.x == point.x && this.y == point.y;
        //          p1.x==p2.x   && p1.y==p2.y
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.x, this.y);
    }

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }

    public int getX() {
        return this.x;
    }

    public void setX(final int x) {
        this.x = x;
    }

    public int getY() {
        return this.y;
    }

    public void setY(final int y) {
        this.y = y;
    }
}
